package com.sanley.piss.model.exceptionUtil.exception;

/**
 * Create By  on 2021/3/5.
 */
public class ServiceException extends RuntimeException{
    private static final long serialVersionUID = -4127574128397705447L;
    /**
     * 错误码
     */
    protected String errorCode;

    /**
     * 错误信息
     */
    protected String errorMsg;

    public ServiceException() {
        super();
    }

    public ServiceException(BaseErrorInfoInterface baseErrorInfoInterface) {
        super(baseErrorInfoInterface.getResultMsg());
        this.errorCode=baseErrorInfoInterface.getResultCode();
        this.errorMsg=baseErrorInfoInterface.getResultMsg();
    }

    public ServiceException(BaseErrorInfoInterface baseErrorInfoInterface, Throwable cause) {
        super(baseErrorInfoInterface.getResultMsg(), cause);
        this.errorCode=baseErrorInfoInterface.getResultCode();
        this.errorMsg=baseErrorInfoInterface.getResultMsg();
    }
public ServiceException(String errorCode,String errorMsg){
        super(errorCode);
        this.errorMsg=errorMsg;
        this.errorCode=errorCode;
}
    public ServiceException(String errorMsg) {
        super(errorMsg);
        this.errorCode="-1";
        this.errorMsg=errorMsg;
    }
    public ServiceException(String errorCode, String errorMsg, Throwable cause) {
        super(errorCode, cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public String getMessage(){
        return errorMsg;
    }

    @Override
    public  Throwable fillInStackTrace() {
        return this;
    }
}
